import { ApiCall } from "tsrpc";
import { ReqParseSSO, ResParseSSO } from "../../../tsrpc/shared/protocols/account/PtlParseSSO";
import { as } from "../../../AccountServiceEntra";

export default async function (call: ApiCall<ReqParseSSO, ResParseSSO>) {
    // TODO
    if (call.req.sso.length == 0) {
        call.error("sso为空", {code: 'SSO_ERROR'});
        return;
    }
    const user = as.parseSSO(call.req.sso);
    if (user == undefined) {
        call.error("账号还没登录", {code: 'SSO_ERROR'});
        return;
    }
    console.error("解析成功")
    call.succ({ user });
}